#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int a[500010] = {0} , c = 0;
	while(cin >> s){
		int len , n = 0 , p = 1;
		len = s.length();
		for(int i = len - 1 ; i >= 2 ; i--){
			if(s[i] <= '9')n += (s[i] - '0') * p;
			else n += (s[i] - 'A' + 10) * p;
			p *= 36;
			
		}
		a[++c] = n;
	}
	sort(a + 1 , a + c + 1);
	int min = 1000000000;
	for(int i = 1 ; i <= c - 1 ; i++){
		int k = a[i + 1] - a[i];
		if(k <= min){
			min = k;
		}
	}
	cout << min << endl;
	return 0;
}
